<!--编辑收货人信息-->
<div id="address-modal" class="modal fade modal_small" tabindex="1" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title">编辑收货地址</h4>
            </div>
            <form action="<?php echo getUrl('order/home/addressEdit')?>" class="form-horizontal" id="address-form" method="post">
                <div class="modal-body">
                    <div class="form-group">
                        <label class="control-label col-md-2">联系人<span class="required">*</span></label>
                        <div class="col-md-9">
                            <input class="form-control required" name="contacts" type="text"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-2">联系方式<span class="required">*</span></label>
                        <div class="col-md-9">
                            <input class="form-control required isMobile" name="mobile" type="tel" maxlength="11"/>
                        </div>
                    </div>
                    <div class="form-group" id="region" data-url="<?php echo getUrl('common/ajaxChangeCheck');?>">
                        <label class="control-label col-md-2">区域<span class="required">*</span></label>
                        <div class="col-xs-3">
                            <select  id="province" name="province_id" class="form-control">
                                <option  value="">选择省份</option>
                                <?php foreach ($province as $p):  ?>
                                    <option value="<?php echo $p['id']?>"><?php echo $p['name']?></option>
                                <?php endforeach;?>
                            </select>
                        </div>
                        <div class="col-xs-3">
                            <select  id="city" name="city_id" class="form-control">
                                <option value="">选择城市</option>
                            </select>
                        </div>
                        <div class="col-xs-3">
                            <select id="county" name="county_id" class="form-control">
                                <option value="">选择区县</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-2">详情地址<span class="required">*</span></label>
                        <div class="col-md-9">
                            <input class="form-control required" name="address" type="text"/>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <input type="hidden" name="order_id" value="<?php echo $info["id"]?>" >
                    <button class="btn default" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> 关闭</button>
                    <button class="btn green field-submit-btn"><i class="fa fa-save"></i> 保存</button>
                    <script type="text/javascript">
                        $(function () {
                            var modal = $("#address-modal");
                            var id = '<?php echo $info["id"]?>';
                            $(".address-edit").live('click',function () {
                                App.blockUI();
                                $.ajax('<?php echo getUrl('order/home/getInfo')?>', {
                                    dataType:'json',
                                    type:'post',
                                    data:{id:id},
                                    error:function(){
                                        show_message({status:0, message:'请求超时'});
                                        App.unblockUI();
                                    },
                                    timeout:60000,
                                    success:function(data,textStatus,jqXHR){
                                        if (data.status == 0){
                                            show_message(data);
                                            return false;
                                        }
                                        modal.find('.has-error').removeClass('has-error').find('.validate_message').remove();
                                        modal.find('.show_message_error').remove();
                                        for(var k in data){
                                            if(k == 'province_id'){
                                                modal.find('[name="'+k+'"]').val(data[k]);
                                                city(data[k], data['city_id']);
                                            }else if(k == 'city_id'){
                                                county(data[k], data['county_id']);
                                            }else{
                                                modal.find('[name="'+k+'"]').val(data[k]);
                                            }
                                        }
                                        setTimeout(function () {
                                            modal.modal();
                                            App.unblockUI();
                                        }, 1000);
                                    }
                                });
                            });
                            $.e_validate.init('#address-form',{modal:modal,ignore:'',successCallback:function(data){
                                var td = '';
                                for (var k in data){
                                    td += '<td>'+data[k]+'</td>';
                                }
                                $(".address-list").html(td);
                            }});
                        });
                    </script>
                </div>
            </form>
        </div>
    </div>
</div>